<?php
/**
 * ApplicationConfigBehavior is a behavior for the application.
 * It loads additional config parameters that cannot be statically 
 * written in config/main
 */
class ApplicationConfigBehavior extends CBehavior
{
    /**
     * Declares events and the event handler methods
     * See yii documentation on behavior
     */
    public function events()
    {
        return array_merge(parent::events(), array(
            'onBeginRequest'=>'beginRequest',
        ));
    }
 
    /**
     * Load configuration that cannot be put in config/main
     */
    public function beginRequest()
    {
    	$modules = array();
    	$model = Module::model()->findAll(); // Todo - should be per application
    	foreach ($model as $item)
    	{
    		$modules[$item->name] = array();// Todo can set parameters here for each module... 
    	}    	
    	//$modules['video'] = array();
    	Yii::app()->setModules($modules);
    }
}
?>